Learning Flex Basics (Part 3) : Working with Containers
Table of Contents
- Introduction
- Building the Containers
- Create the Application Object
- Create a Data Array
- Add a TabNavigator Container for Global Navigation
- Add an HBox and Panel Containers for Main Views
- Add a ViewStack, LinkBar, and Panel Containers for Secondary Views
- Add a Form Container
- Add a Tile Layout Container and Populate It Using a Repeater
- Create a Pseudo Bar Chart Using a Repeater and VBoxes
- Complete Code Listing for containers.mxml
- Where to Go from Here
Add an HBox Layout and Panel Containers for Main Views
The Flex class library contains a number of layout container classes for arranging contents visually on the screen. Here you use two of them for the main navigation views:
- HBox layout container lays out its contents in a row
- Panel container (also used in the first two tutorials), lays out contents horizontally or vertically, and provides a title bar
For the Panel, use data binding to link the height of the Panel container to the height of the TabNavigator container. This is a useful technique for creating relative sizing and minimizing hard-coded sizes that would be tedious to maintain in later UI makeovers or in porting the application to a different display device. You achieve data binding here through curly braces: { and }. The curly braces indicate that the Flex compiler should evaluate the contents inside as an ActionScript expression or variable.
-
Inside the TabNavigator container block, add an HBox container block with the label "View 1: Form/Tile":
<mx:HBox label="View 1: Form/Tile">. </mx:HBox>
-
After the HBox container block, add a Panel container with the label View 2: Pseudo Bar Chart, and
id,height, andtitleproperties as follows:<mx:Panel id="barPanel" label="View 2: Pseudo Bar Chart" title="Pseudo Bar Chart" height="{.9*tabNav.height}"> </mx:Panel